page.tsx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. import React from 'react';
  2. import {Breadcrumb} from "antd";
  3. import {serverGet} from "@/utils/request";
  4. import './rich.css'
  5. import MainTitle from "@/components/MainTitle";
  6. import ContentNotFound from "@/components/ContentNotFound";
  7. import './head.css';
  8. import Image from "next/image"; // 引入样式文件
  9. export const dynamicParams = true
  10. const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL as string
  11. export const generateStaticParams = async () => {
  12. const res = await serverGet<Page<ProductCenter>, { pageNum: number; pageSize: number }>(
  13. "/webSite/getProductByPage",
  14. {pageNum: 1, pageSize: 20}, {
  15. next: {
  16. revalidate: 1800
  17. },
  18. cache: "force-cache"
  19. }
  20. )
  21. return res.data.records.map((item) => ({
  22. id: item.id,
  23. }))
  24. }
  25. async function Page({
  26. params,
  27. }: {
  28. params: Promise<{ id: string }>
  29. }) {
  30. const {id} = await params;
  31. const res = await serverGet<ProductCenter, { id: string }>(
  32. "/webSite/getProductById",
  33. {id}, {
  34. next: {
  35. revalidate: 1800
  36. },
  37. cache: "force-cache"
  38. }
  39. )
  40. if (!res.data) {
  41. return <ContentNotFound/>
  42. }
  43. console.log(111,res.data)
  44. return (
  45. <>
  46. <div className="w-4/5 mx-auto">
  47. <div className="pt-5 sm:pt-10 sm:ml-20 flex gap-2">
  48. <span className="text-sm">您当前的所在位置:</span>
  49. <Breadcrumb
  50. separator=">"
  51. items={[
  52. {title: "产品列表", href: "/products"},
  53. {title: res.data.productName || "产品详情"},
  54. ]}
  55. />
  56. </div>
  57. </div>
  58. <div className="py-6 sm:py-10">
  59. <MainTitle title={"产品详情"} titleLetter={"PRODUCT_DETAIL"}/>
  60. </div>
  61. {/*头部区域*/}
  62. <div className='container'>
  63. {/* 左侧图片区域 */}
  64. <div className='leftSection'>
  65. {/*<img*/}
  66. {/* src={res.data.productUrl ? BASE_URL + res.data.productUrl : "/assets/home/20.png"} // 替换为实际设备图片链接*/}
  67. {/* alt="雷达水位监测仪EN200-D"*/}
  68. {/* className='deviceImg'*/}
  69. {/*/>*/}
  70. <Image
  71. className={"h-50 object-contain"}
  72. src={res.data.productUrl ? BASE_URL + res.data.productUrl : "/assets/home/20.png"}
  73. alt={res.data.productName}
  74. width={1000}
  75. height={1000}
  76. />
  77. </div>
  78. {/* 右侧信息区域 */}
  79. <div className='rightSection'>
  80. <h3 className='productName'>{res.data.productName}</h3>
  81. <p className='model'>{res.data.productModel}</p>
  82. <ul className='featureList'>
  83. {res.data.productIntroduction?.split('·').map((item, index) => (
  84. <li key={index}>{item.trim()}</li>
  85. ))}
  86. </ul>
  87. <div className='specs'>
  88. <p><span className='label'>型号:</span>{res.data.productModel}</p>
  89. <p><span className='label'>品牌:</span>中科盛阳</p>
  90. <p><span className='label'>场景:</span>{res.data.productScene}</p>
  91. </div>
  92. {/* 按钮区域 */}
  93. <div className='buttonGroup'>
  94. <a
  95. href="tel:0731-8531-5153"
  96. className='contactBtn'
  97. >
  98. <span className='phoneIcon'>📞</span> 0731-8531-5153
  99. </a>
  100. <button className='quoteBtn'>获取报价</button>
  101. </div>
  102. </div>
  103. </div>
  104. <div className="ql-editor w-9/10 sm:w-7/10 mx-auto sm:px-20 sm:py-10">
  105. <div className="text-2xl font-bold mb-4 border-b-2 border-blue-600 ql-color-blue">详细信息</div>
  106. </div>
  107. <div
  108. dangerouslySetInnerHTML={{__html: res.data.productDetails as string}}
  109. className="ql-editor w-9/10 sm:w-7/10 mx-auto sm:px-20 sm:py-10"
  110. />
  111. </>
  112. );
  113. }
  114. export default Page;